<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 4.3.2 or newer
 *
 * @package		CodeIgniter
 * @author		ExpressionEngine Dev Team
 * @copyright	Copyright (c) 2008, EllisLab, Inc.
 * @license		http://codeigniter.com/user_guide/license.html
 * @link		http://codeigniter.com
 * @since		Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * Custom CodeIgniter Form Helpers
 *
 * @package		CodeIgniter
 * @subpackage	Helpers
 * @category	Helpers
 * @author		CodeIgniter
 * @link		NA
 */

// ------------------------------------------------------------------------

/**
 * Show Page
 *
 * Lets you show the header and the footer file with the dynamin view
 *
 * @access	public
 * @param	string
 * @param	array
 * @param	mixed
 * @return	mixed	depends on what the array contains
 */	
if ( ! function_exists('show_page'))
{
	function show_page($item, $array=array(), $default = FALSE)
	{
		$CI =& get_instance();
		$CI->load->view('header',$array);
		$CI->load->view($item,$array);
		$CI->load->view('footer',$array);
	}	
}

// ------------------------------------------------------------------------

/**
 * Check User Login
 *
 * Lets you check whether the user is logged in or not
 *
 * @access	public
 * @return	mixed	depends on what the array contains
 */	
if ( ! function_exists('check_user_login'))
{
	function check_user_login()
	{
		$CI =& get_instance();
		$userdata = $CI->session->userdata('user_data');
		if(!isset($userdata['user_login']) || empty($userdata['user_login']))
			redirect(DEFAULT_PAGE);
		
	}	
}

// ------------------------------------------------------------------------

/**
 * Get Login Name
 *
 * Lets you call the login name
 *
 * @access	public
 * @return	mixed	depends on what the array contains
 */	
if ( ! function_exists('get_login_name'))
{
	function get_login_name()
	{
		$CI =& get_instance();
		$userdata = $CI->session->userdata('user_data');
		if(isset($userdata['user_login']) && !empty($userdata['user_login']))
			return $userdata['user_login'];
		else	
			return 'guest';
	}	
}

// ------------------------------------------------------------------------

/**
 * Check Grade
 *
 * Lets you the grade as per the results
 *
 * @access		public
 * @category	function
 * @param  		float
 * @return		mixed	depends on what the array contains
 */	
if ( ! function_exists('check_grade'))
{
	function check_grade($score=0.00)
	{
		$grade = '';
		
		if($score >= 100)
			$grade  = 'Great!! Excellent!! Genius!!';
		else if($score >= 90  && $score < 100)
			$grade  = 'Distinction!! Good on You!!';
		else if($score >= 60  && $score < 90)
			$grade  = 'First Class!! Keep it up!!';
		else if($score >= 40  && $score < 60)
			$grade  = 'Second Class!! Ok!! Can do Better';			
		else
			$grade  = 'Fail!! Need a lot of Improvement!!';
			
		return $grade;
	}	
}

//EOF Form Helper
?>